package com.wnxy.admin.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {
    /** 创建在线文档摘要对象 */
    @Bean
    public Docket createDocket(){
        Docket docket = new Docket(DocumentationType.SWAGGER_2);

        // 设置文档摘要信息：标题、版本、描述
        docket.apiInfo(new ApiInfoBuilder()
                .title("充电桩管理系统测试")
                .version("1.0")
                .description("api接口描述")
                .build()
        );
        docket.select()
                // 扫描的api路径，只扫描Controller
                .apis(RequestHandlerSelectors.basePackage(
                        "com.wnxy.admin.controller"
                ))
                //设置对指定路径下的任意类生成文档
                .paths(PathSelectors.any())
                .build();
        return docket;
    }
}